package com.example.controller;

import com.example.bean.Depart;
import com.example.service.DepartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 徐文祥
 * @since 2023/12/07 01:08
 */

@RestController
@RequestMapping("/provider/depart")
public class DepartController {

    @Autowired
    DepartService departService;

    @GetMapping("/post")
    public boolean saveHandler1(@RequestBody Depart depart){
        return  departService.savaDepart(depart);
    }
    @PostMapping()
    public boolean saveHandler(@RequestBody Depart depart){
        return  departService.savaDepart(depart);
    }

    @DeleteMapping("/{id}")
    public boolean deleteHandler(@PathVariable("id") Integer id){
        return  departService.deleteDepartById(id);
    }

    @PutMapping()
    public boolean updateHanlder(@RequestBody Depart depart){
        return  departService.modifyDepart(depart);
    }

    @GetMapping("/{id}")
    public Depart getHandler(@PathVariable("id") Integer id){
        return departService.getDepartById(id);
    }

    @GetMapping("/list")
    public List<Depart> listHandler(){
        return departService.getAllDepart();
    }
}
